package com.heima.freemarker.demo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * @author itheima
 * @since 2022-07-04
 */
@Controller
public class HelloController {

    @GetMapping("/hello")
    public String hello(Model model) {
        model.addAttribute("name","freemarker");
        Map<String,Object> map = new HashMap<>();
        map.put("name","xiaoming");
        map.put("age",18);
        model.addAttribute("map",map);

        HashMap<String, Object> stus = new HashMap<>();
        stus.put("name","xiaohong");
        stus.put("age",20);
        List<Map<String,Object>> list = new ArrayList<>();
        list.add(stus);
        model.addAttribute("list",list);
        model.addAttribute("stus",stus);
        model.addAttribute("today",new Date());
        return "01-basic";
    }

}
